package com.spring.future.modules.sys.service;

import com.google.common.collect.Lists;
import com.spring.future.common.mybatis.domain.Page;
import com.spring.future.common.mybatis.domain.Pageable;
import com.spring.future.common.utils.Const;
import com.spring.future.common.utils.StringUtils;
import com.spring.future.modules.sys.domain.New;
import com.spring.future.modules.sys.domain.Product;
import com.spring.future.modules.sys.mapper.NewMapper;
import com.spring.future.modules.sys.mapper.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by admin on 2017/1/18.
 */
@Service
public class ProductService {
    @Autowired
    private ProductMapper productMapper;

    public Page findPage(Pageable pageable, Map<String, Object> map) {
        Page<Product> page = productMapper.findPage(pageable, map);
        return page;
    }

    public Product findOne(String id){
        Product product = productMapper.findOne(id);
        List<String> list = Lists.newArrayList();
        List<String> urlList =StringUtils.getSplitList(product.getPicUrl(),"\\|");
        for(String value:urlList){
            list.add(Const.TIANYUURL+value);
        }
        product.setPictureList(list);
        return product;
    }
}
